<?php  if ( ! defined('BASEPATH')) exit('No direct script access allowed');

// ------------------------------------------------------------------------

/**
 * CodeIgniter Date Helpers
 *
 * @package		CodeIgniter Extender
 * @subpackage	Helpers
 * @category	Helpers
 * @author		MukherjeeInfoServices Dev Team
 * @link		http://www.mukherjeeinfoservices.com/ci_extender/user_guide/helpers/mixed_helper.html
 */

// ------------------------------------------------------------------------

	/**
	* Print JSON
	*
	* Print an array to json format
	*
	* @author MukherjeeInfoServices Dev Team <projects@mukherjeeinfoservices.com>
	* @access    public
	* @param	array	a valid array
	* @return    void
	*/
	function print_json($arr)
	{
		if(is_array($arr))
		{
			header('Cache-Control: no-cache, must-revalidate', true);
			header('Expires: Mon, 26 Jul 1997 05:00:00 GMT', true);
			if(strpos($_SERVER['HTTP_ACCEPT'], 'application/json') !== FALSE)
				@header('Content-Type: application/json; charset=UTF-8', true);
			else @header('Content-Type: text/plain; charset=UTF-8', true);
			print json_encode($arr);
		}
		else 
		{
			die('Can not print json data, because variable is not a array');
		}
	}